<?php
session_start();
include "../service/userService.php";
if(isset($_POST["user"])){
    $username = $_POST["user"];
    $pwd = $_POST["pwd"];
    $loggedIn = checkUserAuthenticate($username,$pwd);
    
    if($loggedIn == 3 || $loggedIn == 4){
        
        if($loggedIn == 3){
            $user = mysql_fetch_array(getUserInfor($username));
            $_SESSION['loginuser'] = array($user["USER_ID"],$user["USER_NAME"],$user["USER_TYPE"]);
        }else{
            $company = mysql_fetch_array(getCompanyInfor($username));
            $_SESSION['loginuser'] = array($company["USER_ID"],$company["USER_NAME"],$company["USER_TYPE"]);
        }
        
        echo "<script>window.location.href='../pc/personalInformation.php'</script>";        
    }else{
        echo "<script>window.location.href='../pc/login.php?msg=0'</script>";
        //echo $username;
    }
}else{
    echo "<script>window.location.href='../pc/login.php'</script>";
}


?>